﻿using Microsoft.AspNetCore.Mvc;

namespace MQTT.Server.Controllers
{

    [ApiController]
    [Route("[controller]/[action]")]
    public class MqttManageController : ControllerBase
    {
        private readonly MqttClientController _mqttClientServer;

        public MqttManageController(MqttClientController mqttClientServer)
        {
            _mqttClientServer = mqttClientServer;
        }

        [HttpGet]
        public IActionResult Set(string key, string val)
        {

            _mqttClientServer.PublishMessage(key, val);

            var content = new ContentResult();
            content.StatusCode = 200;
            content.Content = $"key:{key}val{val}";
            content.ContentType = "text/plain";
            return content;
        }

    }
}
